package com.atguigu.srb.core.controller.api;


import com.atguigu.srb.base.util.JwtUtils;
import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.LendItemReturn;
import com.atguigu.srb.core.service.LendItemReturnService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 标的出借回款记录表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/api/core/lendItemReturn")
public class ApiLendItemReturnController {
    @Resource
    LendItemReturnService lendItemReturnService;
    //投资人的回款计划的查询和展示
    //需要的参数是token(获取投资人的userId)以及lendId(用来确认具体的标的)auth认证
    @ApiOperation("投资人的回款计划的查询和展示")
    @GetMapping("/auth/{lendId}")
    public R getLendItemReturnList(@RequestHeader(value = "token",required = false)String token,
                                   @PathVariable("lendId")Long lendId){
        Long userId = JwtUtils.getUserId(token);
        //应该是回款计划的所有状态都查询
        List<LendItemReturn> list = lendItemReturnService.getReturnList(userId,lendId);
        return R.ok().data("items",list);
    }

}

